package com.endava.exceptions.propagation;

/**
 * Main rule: an overriding method cannot throw a more extensive checked exception.
 * 
 * @author Andreea
 * 
 */
public class OverridingEx {
}

/**
 * A newly created checked exception hierarchy.
 * 
 */
class SubException extends Exception {
}

class SubSubException extends SubException {
}

/**
 * Examples of valid and invalid overriding.
 * 
 */
class CC {
	void doStuff() throws SubException {
	}
}

class CC2 extends CC {
	void doStuff() throws SubSubException {
	}
}

//compilation error
class CC3 extends CC {
	// void doStuff() throws Exception {}
}

//overloading methods can throw broader exceptions
class CC4 extends CC {
	void doStuff(int x) throws Exception {
	}
}

class CC5 extends CC {
	void doStuff() {
	}
}

//unchecked exceptions have no influence when overriding a method
class CC6 extends CC {
	void doStuff() throws NullPointerException { 
	}
}